package com.example.springaopdemo.config;

import com.example.springaopdemo.model.ClassRoom;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.web.context.annotation.ApplicationScope;
import org.springframework.web.context.annotation.RequestScope;
import org.springframework.web.context.annotation.SessionScope;

@Configuration
public class ClassRoomConfig {
    @Bean(name = "class")
    public ClassRoom classRoom(){
        return new ClassRoom(1,"这是1号教室");
    }



    @Bean
    @Scope(scopeName = ConfigurableBeanFactory.SCOPE_SINGLETON)
    public ClassRoom single(){
        return new ClassRoom();
    }

    @Bean
    @Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public ClassRoom prototype(){
        return new ClassRoom();
    }


    @Bean
    @RequestScope
    public ClassRoom request(){
        return new ClassRoom();
    }

    @Bean
    @SessionScope
    public ClassRoom session(){
        return new ClassRoom();
    }

    @Bean
    @ApplicationScope
    public ClassRoom application(){
        return new ClassRoom();
    }
}
